<?
/**
 * UserEdit.php
 *
 * This page is for users to edit their account information
 * such as their password, email address, etc. Their
 * usernames can not be edited. When changing their
 * password, they must first confirm their current password.
 *
 */
//include("include/session.php");
?>

<html>
<title>Edit Account Info</title>
<body>

<?
/**
 * User has submitted form without errors and user's
 * account has been edited successfully.
 */
if(isset($_SESSION['useredit'])){
   unset($_SESSION['useredit']);
   ?>
   <div style="color:blue">
   <?
   echo "<h4><p><b>$session->username</b>, your account has been successfully updated.</h4> ";
   ?>
   </div>
   <META HTTP-EQUIV=Refresh CONTENT="3">
   <?
}
else{
?>

<?
/**
 * If user is not logged in, then do not display anything.
 * If user is logged in, then display the form to edit
 * account information, with the current email address
 * already in the field.
 */
if($session->logged_in){
?>

<!--<h1>User Account Edit : <? echo $session->username; ?></h1>-->
<?
if($form->num_errors > 0){
   echo "<td><font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font></td>";
}
?>
<h1 align="center">User Account Information</h1> 
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>Current Password:</td>
<td><input type="password" name="curpass" maxlength="30" value="
<?echo $form->value("curpass"); ?>"></td>
<td><? echo $form->error("curpass"); ?></td>
</tr>

<tr>
<td>New Password:</td>
<td><input type="password" name="newpass" maxlength="30" value="
<? echo $form->value("newpass"); ?>"></td>
<td><? echo $form->error("newpass"); ?></td>
</tr>

<tr>
<td>Email:</td>
<td><input type="text" name="email" maxlength="50" value="
<?
if($form->value("email") == ""){
   echo $session->userinfo['email_address'];
}else{
   echo $form->value("email");
}
?>">
</td>
<td><? echo $form->error("email"); ?></td>
</tr>

<tr>
<td>Name Prefix:</td>
<td><input type="text" name="prefix" maxlength="50" value="
<?
if($form->value("prefix") == ""){
   echo $session->userinfo['prefix'];
}else{
   echo $form->value("prefix");
}
?>">
</td>
</tr>


<tr>
<td>First Name:</td>
<td><input type="text" name="fname" maxlength="50" value="
<?
if($form->value("fname") == ""){
   echo $session->userinfo['fname'];
}else{
   echo $form->value("fname");
}
?>">
</td>
<td><? echo $form->error("fname"); ?></td>
</tr>

<tr>
<td>Last Name:</td>
<td><input type="text" name="lname" maxlength="50" value="
<?
if($form->value("lname") == ""){
   echo $session->userinfo['lname'];
}else{
   echo $form->value("lname");
}
?>">
</td>
</tr>

<tr>
<td>suffix:</td>
<td><input type="text" name="suffix" maxlength="50" value="
<?
if($form->value("suffix") == ""){
   echo $session->userinfo['suffix'];
}else{
   echo $form->value("suffix");
}
?>">
</td>
</tr>

<tr>
<td>Address Number:</td>
<td><input type="text" name="address_num" maxlength="50" value="
<?
if($form->value("address_num") == ""){
   echo $session->userinfo['address_num'];
}else{
   echo $form->value("address_num");
}
?>">
</td>
</tr>

<tr>
<td>Address Street Name:</td>
<td><input type="text" name="address_st_name" maxlength="50" value="
<?
if($form->value("address_st_name") == ""){
   echo $session->userinfo['address_st_name'];
}else{
   echo $form->value("address_st_name");
}
?>">
</td>
</tr>

<tr>
<td>City:</td>
<td><input type="text" name="city" maxlength="50" value="
<?
if($form->value("city") == ""){
   echo $session->userinfo['city'];
}else{
   echo $form->value("city");
}
?>">
</td>
</tr>
</table>

<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>State:</td>
<td><input type="text" name="state" maxlength="50" value="
<?
if($form->value("state") == ""){
   echo $session->userinfo['state'];
}else{
   echo $form->value("state");
}
?>">
</td>
</tr>

<tr>
<td>Zip Code:</td>
<td><input type="text" name="zip" maxlength="50" value="
<?
if($form->value("zip") == ""){
   echo $session->userinfo['zip'];
}else{
   echo $form->value("zip");
}
?>">
</td>
</tr>

<tr>
<td>Gender:</td>
<td><input type="text" name="gender" maxlength="50" value="
<?
if($form->value("gender") == ""){
   echo $session->userinfo['gender'];
}else{
   echo $form->value("gender");
}
?>">
</td>
</tr>

<tr>
<td>Home Phone:</td>
<td><input type="text" name="phone_home" maxlength="50" value="
<?
if($form->value("phone_home") == ""){
   echo $session->userinfo['phone_home'];
}else{
   echo $form->value("phone_home");
}
?>">
</td>
</tr>

<tr>
<td>Cell Phone:</td>
<td><input type="text" name="phone_cell" maxlength="50" value="
<?
if($form->value("phone_cell") == ""){
   echo $session->userinfo['phone_cell'];
}else{
   echo $form->value("phone_cell");
}
?>">
</td>
</tr>

<tr>
<td>Other Phone:</td>
<td><input type="text" name="phone_other" maxlength="50" value="
<?
if($form->value("phone_other") == ""){
   echo $session->userinfo['phone_other'];
}else{
   echo $form->value("phone_other");
}
?>">
</td>
</tr>

<tr>
<td>Employment Status:</td>
<td><input type="text" name="employee_status" maxlength="50" value="
<?
if($form->value("employee_status") == ""){
   echo $session->userinfo['employee_status'];
}else{
   echo $form->value("employee_status");
}
?>">
</td>
</tr>

<tr>
<td>Current Employer:</td>
<td><input type="text" name="curr_employer" maxlength="50" value="
<?
if($form->value("curr_employer") == ""){
   echo $session->userinfo['curr_employer'];
}else{
   echo $form->value("curr_employer");
}
?>">
</td>
</tr>

<tr>
<td>Referred By:</td>
<td><input type="text" name="referredby" maxlength="50" value="
<?
if($form->value("referredby") == ""){
   echo $session->userinfo['referredby'];
}else{
   echo $form->value("referredby");
}
?>">
</td>
</tr>

<tr>
<td>Legal Barriers:</td>
<td><input type="text" name="legalbarriers" maxlength="50" value="
<?
if($form->value("legalbarriers") == ""){
   echo $session->userinfo['legalbarriers'];
}else{
   echo $form->value("legalbarriers");
}
?>">
</td>
</tr>
</table>

<table>
<tr><td colspan="2" align="right">
<input type="hidden" name="subedit" value="1">
<input type="submit" value="Update Account"></td></tr>
<tr><td colspan="2" align="left"></td></tr>
</table>
</form>


<?
}
}

?>

</body>
</html>
